#include "define.h"

Status InitQueue(SqQueue &Q){
    Q.buff = (QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
    if(!Q.buff) return ERROR;
    Q.front = Q.rear = 0;
    return OK;
}
bool Is_empty(SqQueue &Q){
    return Q.front == Q.rear;
}
bool Is_overflow(SqQueue &Q){
    return (Q.rear+1)%MAXQSIZE == Q.front;
}
Status EnQueue(SqQueue &Q, QElemType e){
    if(Is_overflow(Q)) return ERROR;
    Q.buff[Q.rear] = e;
    Q.rear = (Q.rear+1)%MAXQSIZE;
    return OK;
}
Status DeQueue(SqQueue &Q, QElemType &e){
    if(Is_empty(Q)) return ERROR;
    e = Q.buff[Q.front];
    Q.front = (Q.front+1)%MAXQSIZE;
    return OK;
}
